<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>秒杀</title>
</head>
<script type="text/javascript" src="/js/jquery-3.5.1.min.js"></script>
<script type="text/javascript">
    function flashsale() {
        $.ajax({
            url:"/order/getMSAddr",
            type: "POST",
            data: "userId=u12345&content=helloworld.book",
            cache: false,
            success:function (data) {
                alert(data.data)
                if(data.code == 200) {
                    $.ajax({
                        url: "/order" + data.data,
                        type: "POST",
                        data: "userId=u12345&content=helloworld.book",
                        cache: false,
                        success:function (data) {
                            if(data.code == 200) {
                                alert("抢购成功，等待支付！订单id = " + data.data.orderId)
                                window.location.href = "/goods/waitPay";
                            } else if (data == "fail") {
                                alert("抢购失败，请重试！")
                            }
                        },
                        error:function () {
                        }
                    });
                } else {
                    alert(data.msg);
                }

            },
            error:function () {
            }
        });
    }
</script>
<body>
<input type="button" value="抢购" onclick="flashsale()" />
</body>
</html>